package cn.sdstudio.controller;


import cn.sdstudio.dto.RouteRequestDTO;
import cn.sdstudio.service.MapRouterService;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Zyq
 * @version 1.0
 * @date 2025/4/29 周二
 */
@RestController
@RequestMapping("route")
@Schema(description = "地图路线接口")
@Slf4j
@RequiredArgsConstructor
public class MapRouterController {


    private final MapRouterService mapRouterService;


    @PostMapping
    @Schema(description = "路线分析")
    public JSONObject getRouterInfo(@RequestBody @Schema(description = "路线请求体") RouteRequestDTO routeRequestDTO) {

        //TODO:未完成
        log.info("routeRequestDTO:{}", routeRequestDTO);
        JSONObject routeFromAddress = mapRouterService.getRouteFromAddress(routeRequestDTO.getOrigin()
                , routeRequestDTO.getDestination()
                , routeRequestDTO.getTravel());

        log.info("routeFromAddress:{}", routeFromAddress);
        log.info("====================================");
        return routeFromAddress;
    }
}
